//import java.util.Date;
//import java.util.concurrent.*;
//
//
///**
// * Callable中有一个call()函数，但是call()函数有返回值
// * 能够将任务执行结果返回
// */
//class WorkerThread implements Callable<Long> {
//
//    private String command;
//    public WorkerThread(String s) {
//        this.command = s;
//    }
//
//
//    @Override
//    public Long call() {
//        System.out.println(Thread.currentThread().getName() + " Start. Time = " + new Date());
//        processCommand();
//        System.out.println(Thread.currentThread().getName() + " End. Time = " + new Date() );
//
//        return Thread.currentThread().getId();
//    }
//
//
//    private void processCommand() {
//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Override
//    public String toString() {
//        return this.command;
//    }
//}
//
//
//
//
///**
// * 线程池测试类
// */
//public class ScheduledExecutorServiceTest {
//    public static void main(String[] args) {
////        scheduleWithDelay();
//        //scheduleAtRate();
//
//        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(3);
//        WorkerThread task = new WorkerThread("do some thing");
//        FutureTask<Long> futureTask = new FutureTask<Long>(task);
//
//        scheduledExecutorService.scheduleAtFixedRate(task,3000, 3000, TimeUnit.MILLISECONDS);
//
//
//    }
//
//
//
////    /**
////     * scheduleWithFixedDelay 中的 delayTime
////     * 代表每次线程任务执行完毕后，直到下一次开始执行开始之前的时间间隔。
////     */
////    public static void scheduleWithDelay() {
////        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(3);
////        WorkerThread workerThread = new WorkerThread("do some thing");
////        scheduledExecutorService.scheduleWithFixedDelay(workerThread, 3000, 3000, TimeUnit.MILLISECONDS);
////    }
////    /**
////     * scheduleAtFixedRate 中的 delayTime/period 表示从线程池中首先开始执行的线程算起，假设period为1s，
////     * 若线程执行了5s，那么下一个线程在第一个线程运行完后会很快被执行。
////     */
////    public static void scheduleAtRate() {
////        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(3);
////        WorkerThread workerThread = new WorkerThread("do some thing");
////        scheduledExecutorService.scheduleAtFixedRate(workerThread, 3000, 3000, TimeUnit.MILLISECONDS);
////    }
//}